#!/usr/bin/env python
##HACKABOT_HELP##
# Look up a word in the Urban Dictionary.
# !urban word
##HACKABOT_HELP##

import SOAPpy
import sys

import hackabot
from hackabot.client import Client

server = SOAPpy.SOAPProxy("http://api.urbandictionary.com/soap")

hbc = Client()
msg = hbc.readline()
nick = hbc.sent_by()
if msg:
    urban = server.lookup("7df8eccad5391dbbb45e81fa77f4c1a8", msg)
    if len(urban):
        if(len(urban[0].definition) < 256):
            print "send %s: %s" % (nick, urban[0].definition.strip())
        else:
            print "send %s: %s" % (nick, urban[0].url.strip())
    else:
        print "send %s: I couldn't find a definition for %s" % (nick, msg)
